
////////////////////////////////////////////////////////////
//	File:		"AL_ThreadPoolManager.h"
//	Author:		[AL] Anthony Lundquist
//	Created:	[AL] March 14, 2010
//	Purpose:	Manages all of the thread pools
//				- Singleton
////////////////////////////////////////////////////////////

#ifndef AL_THREADPOOLMANAGER_H_
#define AL_THREADPOOLMANAGER_H_

#include <list>
#include <vector>

class AL_Task;
class TaskThread;

class AL_ThreadPoolManager
{

public:

	/* Public Data Members */

protected:

	/* Protected Data Members */

private:

	std::list<AL_Task*>			m_vTaskPool;
	std::vector<TaskThread*>	m_vRunningThreads;
	int							m_nNumDormentThreads;

	/* Private Data Members */
	static AL_ThreadPoolManager				sm_Instance;

	/* Disabled Functions */
	AL_ThreadPoolManager(const AL_ThreadPoolManager& C);
	AL_ThreadPoolManager& operator=(const AL_ThreadPoolManager& C);

public:
	void	Init(void);
	void	Shutdown(void);
	void	CreateThreadPool(int _nTryMaxThreads, bool _bRunAsSerial=false);
	void	SendTask(AL_Task* _pTask);
	void	UpdatePool(float _fDelta);

	////////////////////////////////////////////////////////////
	//	Function:	Accessors
	//	Created:	[AL] March 14, 2010
	//	Purpose:	Returns a specific data member.
	//	Out:		The data member.
	////////////////////////////////////////////////////////////
	inline int GetTotalThreads()		{	return (int)m_vRunningThreads.size();	}
	int GetNumDormentThreads()			{	return m_nNumDormentThreads;			}

	////////////////////////////////////////////////////////////
	//	Function:	Mutators
	//	Created:	[AL] March 14, 2010
	//	Purpose:	Sets a specific data member.
	//	In:			The new value.
	////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////
	//	Function:	GetInstance
	//	Created:	[AL] March 14, 2010
	//	Purpose:	Returns the singleton's instance.
	//	Out:		The singleton's instance.
	////////////////////////////////////////////////////////////
	static AL_ThreadPoolManager* GetInstance();

protected:

	/* Protected Functions */

private:

	/* Private Functions */

	////////////////////////////////////////////////////////////
	//	Function:	Constructor
	//	Created:	[AL] March 14, 2010
	//	Purpose:	Initializes the object.
	////////////////////////////////////////////////////////////
	AL_ThreadPoolManager();

	////////////////////////////////////////////////////////////
	//	Function:	Destructor
	//	Created:	[AL] March 14, 2010
	//	Purpose:	Deallocates the object.
	////////////////////////////////////////////////////////////
	~AL_ThreadPoolManager();

};

#endif
